home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / win / vb / syswtch.exe / PLANS.BAS < prev    next >
Encoding:
BASIC Source File  |  1991-11-14  |  5.3 KB  |  190 lines

  1. DefInt A-Z
  2.  
  3. Sub Frame (F As Form, L, T, H, W)
  4.   F.DrawWidth = 1
  5.   F.forecolor = &HE0E0E0
  6.   'bottom:
  7. F.Line (L + F.DrawWidth, T + H + OffSet)-(L + W - F.DrawWidth, T + H + OffSet)
  8.   
  9.   'right:
  10. F.Line (L + W + OffSet, T + F.DrawWidth)-(L + W + OffSet, T + H + OffSet - F.DrawWidth)
  11.  
  12. F.forecolor = &H808080
  13.   'top:
  14.  F.Line (L - BigOffSet + F.DrawWidth, T - BigOffSet)-(L + W + BigOffSet - F.DrawWidth, T - BigOffSet)
  15.   
  16.   'left:
  17. F.Line (L - BigOffSet, T + F.DrawWidth - BigOffSet)-(L - BigOffSet, T + H + BigOffSet - F.DrawWidth)
  18.  
  19. End Sub
  20.  
  21. Sub Frame2 (F As Form, L, T, H, W)
  22.   F.DrawWidth = 2
  23. F.forecolor = &H808080
  24.   'bottom:
  25. F.Line (L + F.DrawWidth, T + H + OffSet)-(L + W - F.DrawWidth, T + H + OffSet)
  26.   
  27.   'right:
  28. F.Line (L + W + OffSet, T + F.DrawWidth)-(L + W + OffSet, T + H + OffSet - F.DrawWidth)
  29.  
  30.   F.forecolor = &HE0E0E0
  31.  
  32.   'top:
  33.  F.Line (L - BigOffSet + F.DrawWidth, T - BigOffSet)-(L + W + BigOffSet - F.DrawWidth, T - BigOffSet)
  34.   
  35.   'left:
  36. F.Line (L - BigOffSet, T + F.DrawWidth - BigOffSet)-(L - BigOffSet, T + H + BigOffSet - F.DrawWidth)
  37.  
  38.  
  39. End Sub
  40.  
  41. Sub ReadProf ()
  42. x = ReadFunc("ConfigName1", NameC(1))
  43. x = ReadFunc("ConfigName2", NameC(2))
  44. x = ReadFunc("ConfigName3", NameC(3))
  45. x = ReadFunc("ConfigName4", NameC(4))
  46. x = ReadFunc("ConfigName5", NameC(5))
  47. x = ReadFunc("ConfigFile1", FileC(1))
  48. x = ReadFunc("ConfigFile2", FileC(2))
  49. x = ReadFunc("ConfigFile3", FileC(3))
  50. x = ReadFunc("ConfigFile4", FileC(4))
  51. x = ReadFunc("ConfigFile5", FileC(5))
  52. End Sub
  53.  
  54. Sub WritProf ()
  55. Const App = "Syswitch"
  56. Const Ini = "SYSWITCH.INI"
  57. x = WritePrivateProfileString(App, "ConfigFile1", FileC(1), Ini)
  58. x = WritePrivateProfileString(App, "ConfigFile2", FileC(2), Ini)
  59. x = WritePrivateProfileString(App, "ConfigFile3", FileC(3), Ini)
  60. x = WritePrivateProfileString(App, "ConfigFile4", FileC(4), Ini)
  61. x = WritePrivateProfileString(App, "ConfigFile5", FileC(5), Ini)
  62. x = WritePrivateProfileString(App, "ConfigName1", NameC(1), Ini)
  63. x = WritePrivateProfileString(App, "ConfigName2", NameC(2), Ini)
  64. x = WritePrivateProfileString(App, "ConfigName3", NameC(3), Ini)
  65. x = WritePrivateProfileString(App, "ConfigName4", NameC(4), Ini)
  66. x = WritePrivateProfileString(App, "ConfigName5", NameC(5), Ini)
  67. End Sub
  68.  
  69. Sub CopyFile (Source As String)
  70. x = FALSE
  71. If UCase$(Source) = "SYSTEM.INI" Then x = MsgBox("Restart using current SYSTEM.INI?", 4, "No Change")
  72. If x = IDYES Then RestartProc
  73. If x = IDNO Then Exit Sub
  74. Destination$ = Windir + "\" + "System.ini"
  75. DestinationBack$ = Windir + "\" + "system.bak"
  76. Source$ = Windir + "\" + Source
  77. On Error Resume Next
  78. Kill DestinationBack$
  79. Name Destination$ As DestinationBack$
  80.  
  81. Open Source$ For Binary As #1
  82. whole = LOF(1) \ 32000
  83.  
  84. part = LOF(1) Mod 32000
  85. If whole + part = 0 Then MsgBox Source$ + " not found.": Close : ReadProf: Exit Sub
  86. buffer$ = String$(32000, 0)
  87. start& = 1
  88. Open Destination$ For Binary As #2
  89. On Error GoTo ErrProc
  90. For x = 1 To whole
  91.        Get #1, start&, buffer$
  92.        Put #2, start&, buffer$
  93.        start& = start& + 32000
  94. Next x
  95. buffer$ = String$(part, 0)
  96. Get #1, start&, buffer$
  97. Put #2, start&, buffer$
  98. Close
  99. Call RestartProc
  100. Exit Sub
  101.  
  102.  
  103. ErrProc:
  104. MsgBox "Disk error"
  105. Kill Destination$
  106. Name DestinationBack$ As Destination$
  107. End
  108. End Sub
  109.  
  110. Sub RestartProc ()
  111. Okay% = ExitWindows(&H42, 0)
  112. If Okay% = 0 Then MsgBox "Cannot Restart Windows", 32, "Win Restart"
  113. End
  114. End Sub
  115.  
  116. Function ReadFunc (Desire$, Destination$)
  117. Default$ = "Default Configuration"
  118. If Mid$(Desire$, 7, 1) = "F" Then Default$ = "SYSTEM.INI"
  119. RLen = GetPrivateProfileString("Syswitch", Desire$, Default$, ReadString, 128, "Syswitch.INI")
  120. Destination$ = Left$(ReadString, RLen)
  121. End Function
  122.  
  123. Function GetHighLight () As Integer
  124. For I = 0 To 4
  125. If Form1.Option1(I).Value = TRUE Then GetHighLight = I
  126. Next I
  127. End Function
  128.  
  129. Sub Openfile (C As Control)
  130.    WorkingFileName = Windir + "\SYS2.TXT"
  131.     OpenMode% = READFILE
  132.    FileNum% = Fileopener(WorkingFileName, OpenMode%, 0)
  133.    If FileNum% = 0 Then GoTo OpenErr
  134.   On Error GoTo OpenErr
  135.   If LOF(FileNum%) > 60000 Then
  136.     Msg$ = "Sorry your file is too large to edit."
  137.     MsgBox Msg$, 16, "File Too Big"
  138.     Exit Sub
  139.   End If
  140.   Do Until EOF(FileNum%)
  141.   Line Input #FileNum%, NextLine$
  142.     LineFromFile$ = LineFromFile$ + NextLine$ + Chr$(13) + Chr$(10)
  143.   Loop
  144. C.Text = LineFromFile$
  145. Close FileNum%
  146. Exit Sub
  147.  
  148. OpenErr:
  149. MsgBox "Problem reading " + WorkingFileName
  150. C.Text = "Couldn't read instructions file"
  151. Exit Sub
  152.  
  153. End Sub
  154.  
  155. Function Fileopener (NameToUse$, Mode%, RecordLen%) As Integer
  156.   Const READFILE = 2
  157.   FileNum% = FreeFile
  158.   On Error GoTo OpenerError
  159.   Open NameToUse For Input As FileNum%
  160.   Fileopener = FileNum%
  161.  Exit Function
  162.  
  163. OpenerError:
  164. FileOpner = 0
  165. Exit Function
  166. End Function
  167.  
  168. Sub CommandTest ()
  169.     Com$ = Command$
  170.     If Com$ = "" Then Exit Sub
  171. DirCheck:
  172.     Slash = InStr(Com$, "\")
  173.     If Slash = 0 Then GoTo DirGone
  174.     If Slash = Len(Com$) Then GoTo CommandError
  175.     Com$ = Mid$(Com$, Slash + 1)
  176.     GoTo DirCheck
  177. DirGone:
  178.     If Com$ = "" Then Exit Sub
  179.     If Len(Com$) > 12 Then GoTo CommandError
  180.     Period = InStr(Com$, ".")
  181.     If Period < 1 Or Period > 9 Then GoTo CommandError
  182.     If Len(Mid$(Com$, Period + 1)) > 3 Then GoTo CommandError
  183.     CopyFile (Com$)
  184.     Exit Sub
  185. CommandError:
  186. MsgBox Command$ + " is not a legal file name."
  187. Exit Sub
  188. End Sub
  189.  
  190.